﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages.Admin
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Admin_Add.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-08-26   Created by 杨光远 V1.00.0000
    /// 功能说明：用户信息添加
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Admin_Add : Component.PageBase
    {
        #region---基本变量实例化---
        Vehicle.BLLShow.AdminShow admin = new Vehicle.BLLShow.AdminShow();
     //   Vehicle.BLL.Admin b_Admin = new Vehicle.BLL.Admin();//实例化逻辑层用户变量
     //   Vehicle.BLL.Log b_Log = new Vehicle.BLL.Log();//实例化逻辑层日志变量
        Vehicle.Model.AdminInfo m_AdminInfo = new Vehicle.Model.AdminInfo();//实例化通用实体层变量
        #endregion

        #region---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                admin.Admin_DropDownListBind2(Drop_R_ID);
              //  b_Admin.DropDownListBind2(Drop_R_ID);//绑定角色
            }
        }
        /// <summary>
        /// 添加事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Add_Click1(object sender, EventArgs e)
        {
            //添加前判断是否已经有该登录帐号的用户
            //b_Admin.GetModel(new Vehicle.Model.ComponentsInfo("Admin", "A_LoginID", txt_A_LoginID.Text.Trim(), "1", "1", "A_IsDelete", "1", "A_ID")).Rows.Count == 0)
            if (admin.GetModel(new Vehicle.Model.ComponentsInfo("Admin", "A_LoginID", txt_A_LoginID.Text.Trim(), "1", "1", "A_IsDelete", "1", "A_ID")).Rows.Count == 0)
            {
                m_AdminInfo.A_LoginID = txt_A_LoginID.Text.Trim();//登录账号
                m_AdminInfo.A_PassWord =Vehicle.Common.TextHelper.Encrypt(txt_A_PassWord.Text.Trim());//用户密码
                m_AdminInfo.A_Name = txt_A_Name.Text.Trim();//用户名
                m_AdminInfo.R_ID = Vehicle.Common.TextHelper.StringToInt(Drop_R_ID.SelectedValue);//角色编号
                m_AdminInfo.A_IsDelete = 0;//是否删除
                m_AdminInfo.A_LastTime = DateTime.Now;//最后更新时间 默认为当前时间
                admin.Admin_Add(m_AdminInfo);
                admin.Log_Add(new Vehicle.Model.LogInfo(session_ID, DateTime.Now, "成功添加新用户" + this.txt_A_Name.Text.Trim() + "的信息"));//添加日志
                //b_Admin.Add(m_AdminInfo);//添加数据
                //b_Log.Add(new Vehicle.Model.LogInfo (session_ID,DateTime.Now,"成功添加新用户"+this.txt_A_Name.Text.Trim()+"的信息"));//添加日志
                Common.MessageHelper.AlertRedirect("用户信息添加成功", "Main.aspx");
            }
            else
            {
                Common.MessageHelper.Alert("已经有相同帐号的用户,请重新填写");
            }

        }
        #endregion
    }
}
